In an Oracle database, order by or group by, index creation and re-creation, distinct operations, Union intersect Minus Sort-merge joins, Analyze operations, Exceptions , and so on, can produce a lot of temporary data. If you have a table of employee information, the database is the time to set up records to save. If a user queries by using the ORDER by sort statement to specify the sort by employee number, all the records that are created after sor
"It's an old system." Oracle9i a table with more than 100 million data in a database, and when the table was recently queried for a long time, the Web page was blank, so consider optimizing the table. The optimization plan is as follows:
1. Create a temporary table
Create Global temporary
The MySQL temp table is divided into temporary tables used by the system and temporary tables used by the user.The temporary table used by the system means that MySQL relies on temporary tables to complete the process when executing certain SQL statements. The situation of temporary tables used by the system can be divided into the following types:* The columns i
TABLE 10242 pk_emp INDEX 10243 BONUS table 10244 salgrade tableSql> Col table_name for a10sql> Col tablespace_name for a10sql> Select Table_name,tablespace_name,blocks,empty_ Blocks from dba_tables where owner= ' SCOTT ';TABLE_NAME tablespace BLOCKS empty_blocks------------------------------------------BONUS userssalgrade USERS EMP SYSTEM 5 3Sql> Select segment_name,segment_type,tablespace_name,bytes/1024
temp table will be truncated
4 when to use temporary tables
1, when the table associated with a SQL statement is 2 and above, and is associated with some small tables. A large table can be split and a smaller set of results is stored in a temporary table.
2, the program
temporary table.Create a temporary tableCreate temporary table name like directory table nameDelete temporary tableDrop temporary table name. (Temporary keyword here, you can avoid the wrong deletion of the common table with the same name.) )drop table name.Changing the tab
temporal tables and SQL Server temp tablesSQLSERVERTemp tableYou can also create temporary tables. Temporary tables are similar to permanent tables, but temporary tables are stored in tempdb and are automatically deleted when they are no longer in use.There are both local and global types of temporary tables, which differ in name, visibility, and availability. The name of the local temporary table begins w
Label: Temp table: Table in memory, data in memory. Memory table: Table on disk, data in memory. Modify the size of the staging table and memory table in the My.cnf file: [Mysqld] #
. TempTable to name it, the table can persist until the database is restarted. 2. Manually delete the drop table Temptablename Description: The drop TABLE statement explicitly drops the temporary table, otherwise the temporary table will be automatically dropped by the syste
When IDENTITY_INSERT is set to OFF, you cannot insert an explicit value into the identity column in table ' #TT '.I was in SQL Server to write the stored procedure encountered this error, then thought: how the temporary table has a primary key, I also did not set the primary key.Then I worked with my colleagues to debug, and finally found out. The reason is that I took out the real data
created and destroyed when desired.Applicable situation:Table variable: If it is a small amount of data, then use a table variable. The cost of using table variables is less than temporary tables. Where the actual project is used, such as bulk deletion, you need to pass multiple IDs as parameters, some people will splice the ID string and then parse it in the database; My approach is usually to pass the XM
Global temporary represents a globally temporary tableMetadata for temporary tables is stored in the data dictionaryAllocate space for a segment of this table only when the first DML command occursThe visible range of temporal table data should be session level or transaction levelThe on commit keyword determines when a session or transaction level is built, on commit DELETE rows represents the transaction
I. Temporary table space contraction
1.1 Description
About Oracle's temporary tablespace, a blog has been collated before:
Oracle Temp temporary table space
http://blog.csdn.net/tianlesoftware/article/details/4697417
The following operations can take up a large amount of temporary:
1, users perform IMP/EXP Import export operations, will use a large number of te
Atitit.mysql the use of the Oracle with AS Mode temp table pattern CTE statement to reduce the structural MSSQL SQL for subqueries Server:1. With ... as (...) in the MySQL what should be said in 12. Sub-query and query nesting is mainly easy to improve readability, 23. the solution in MYSQL :: temp table. 24. Seo bla
data file, increase data file, set file Auto-expand), sometimes you need to distribute temporary data files to different disk partitions, improve IO performance, and also need to delete, add temporary tablespace data files.Sql> ALTER tablespace TEMP 2 ADD tempfile '/u04/gsp/oradata/temp02.dbf ' 3 SIZE 4G 4 autoextend on 5 NEXT 128M 6 MAXSIZE 6G;sql> ALTER tablespace tmpadd tempfile '/u03/eps/oradata/temp02.dbf ' SIZE 64G autoextend OFF;Delete a data
Oracle database The process of creating temporary tables and the contrast with the different points of the SQL Server Temp table is the main content of this article, let's take a look at this part of the content, we hope to be able to help you.
1. Introduction
In addition to saving permanent tables, Oracle databases can also create temporary tables temporary tables. These temporary tables are used to hold
Problem:
Recently, the online MySQL found a slow SQL, each time to query more than 1000ms, seriously affect the user experienceToday hollow to diagnose, record as follows:SQL Original sentence:[HTML]View PlainCopyprint?
SELECT r.object_id as CardId, COUNT (1) as Attachs from Hzresource_object R
Left JOIN
(SELECT card_id from Card_member WHERE user_id = #uid # and card_member.deleted=0
UNION
SELECT card_id from card_subscribed where user_id = #uid # and card_subscribed.deleted
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.